<?php
class counter_trigger_base
{
  private $_id;
  private $_type;
  private $_name;
  private $_alias;
  private $_counters;
  private $_key1;
  private $_key2;
  private $_key3;
  
  #the following should not be exported as an array
  private $_props_exception_list;
  
  # private methods
  
  private function _remove_from_export($properties)
  {
    if( empty($property) ) return;
    
    if( !is_array($this->_props_exception_list) )
    {
      $this->_props_exception_list = array(); 
    }
    
    if( is_string($properties) )
    {
      $this->_props_exception_list[] = $properties;
    }
    
    if( is_array($properties) )
    {
      array_merge($this->_props_exception_list, $properties);
    }
    
  }
  
  # public methods
  
  public function _construct()
  {
    $this->SetId();
    $this->SetName();
    $this->SetAlias();
    $this->SetType();
    $this->_counters = array();
    $this->_remove_from_export('_props_exception_list');
  }
  
  public function SetId($id = -1)
  {
    $this->_id = $id;
  }
    
  public function GetId()
  {
    return $this->_id;
  }
  
  public function SetType($type = NULL)
  {
    $this->_type = $type;
  }
  
  public function GetType()
  {
    return $this->_type;
  }
  
  public function SetName($name = '')
  {
    $this->_name = $name;
  }
   
  public function GetName()
  {
    return $this->_name;
  }
  
  public function SetAlias($alias = '')
  {
    $this->_alias = $alias;
  }
  
  public function GetAlias()
  {
    return $this->_alias;
  }
  
  public function SetKey1($keyvalue = -1)
  {
    $this->_key1 = $keyvalue;
  }
  
  public function GetKey1()
  {
    return $this->_key1;
  }
    
  public function SetKey2($keyvalue = -1)
  {
    $this->_key2 = $keyvalue;
  }
  
  public function GetKey2()
  {
    return $this->_key2;
  }
     
  public function SetKey3($keyvalue = -1)
  {
    $this->_key3 = $keyvalue;
  }
  
  public function GetKey3()
  {
    return $this->_key3;
  }
   
  public function Fire()
  {
    if( empty($this->_counters) ) return FALSE;
    /*do count here*/
    return TRUE;
  }

  public function AsArray()
  {
    $tmp = get_class_vars( get_class($this) );
    
    $ret = array();
    foreach ($tmp as $k => $v)
    {
      if( in_array($k, $this->_props_exception_list) ) continue;
      $ret[trim($k, '_')] = $v;
    }
    
    return $ret;
  }
  
}
?>
